package com.android.justcook;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import camp.android.justcook.R;

public class RecipesListAdapter extends BaseAdapter {
	private final LayoutInflater inflater;
	private final String[] meals;
	private final String[] mealsPoints;
	private final String[] mealsDescriptions;
	private final boolean REC_FAV = false;
	public RecipesListAdapter(LayoutInflater inflater, String[] meals, String[] mealsPoints, String[] mealsDescriptions) {
		this.inflater = inflater;
		this.meals = meals;
		this.mealsPoints = mealsPoints;
		this.mealsDescriptions = mealsDescriptions;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return meals.length;
	}
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return meals[position];
	}
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View item = inflater.inflate(R.layout.recipe_item, parent, false);
		((TextView)item.findViewById(R.id.recipe_button)).setText(meals[position]);
		((TextView)item.findViewById(R.id.recipe_subtext)).setText(mealsDescriptions[position]);
		((TextView)item.findViewById(R.id.recipe_points)).setText(mealsPoints[position] + " pts");
		if (REC_FAV) ((ImageView)item.findViewById(R.id.favorite)).setBackgroundResource(R.drawable.starempty);
		else ((ImageView)item.findViewById(R.id.favorite)).setBackgroundResource(R.drawable.starfull);

		return item;
	}
}
